package com.Pawtrack.info.service.impl;

import java.util.List;
import com.Pawtrack.common.utils.DateUtils;
import com.Pawtrack.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.Pawtrack.info.mapper.PetLocationMapper;
import com.Pawtrack.info.domain.PetLocation;
import com.Pawtrack.info.service.IPetLocationService;

/**
 * 宠物定位Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-14
 */
@Service
public class PetLocationServiceImpl implements IPetLocationService 
{
    @Autowired
    private PetLocationMapper petLocationMapper;

    /**
     * 查询宠物定位
     * 
     * @param id 宠物定位主键
     * @return 宠物定位
     */
    @Override
    public PetLocation selectPetLocationById(Long id)
    {
        return petLocationMapper.selectPetLocationById(id);
    }

    /**
     * 查询宠物定位列表
     * 
     * @param petLocation 宠物定位
     * @return 宠物定位
     */
    @Override
    public List<PetLocation> selectPetLocationList(PetLocation petLocation)
    {
        // 自动设置当前用户ID，确保只能查询自己的数据
        if (petLocation != null) {
            petLocation.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        }
        return petLocationMapper.selectPetLocationList(petLocation);
    }

    /**
     * 新增宠物定位
     * 
     * @param petLocation 宠物定位
     * @return 结果
     */
    @Override
    public int insertPetLocation(PetLocation petLocation)
    {
        // 自动设置创建人为当前用户ID
        petLocation.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        petLocation.setCreateTime(DateUtils.getNowDate());
        return petLocationMapper.insertPetLocation(petLocation);
    }

    /**
     * 修改宠物定位
     * 
     * @param petLocation 宠物定位
     * @return 结果
     */
    @Override
    public int updatePetLocation(PetLocation petLocation)
    {
        // 自动设置更新人为当前用户ID
        petLocation.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        petLocation.setUpdateTime(DateUtils.getNowDate());
        return petLocationMapper.updatePetLocation(petLocation);
    }

    /**
     * 批量删除宠物定位
     * 
     * @param ids 需要删除的宠物定位主键
     * @return 结果
     */
    @Override
    public int deletePetLocationByIds(Long[] ids)
    {
        return petLocationMapper.deletePetLocationByIds(ids);
    }

    /**
     * 删除宠物定位信息
     * 
     * @param id 宠物定位主键
     * @return 结果
     */
    @Override
    public int deletePetLocationById(Long id)
    {
        return petLocationMapper.deletePetLocationById(id);
    }
}
